/****************************************************
          File Name:msgstatus.c
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Thu 11 Sep 2014 02:42:35 PM CST
*****************************************************/

#include"msg.h"

int main(int argc,char *argv[])
{
    struct msqid_ds buf;

    if(argc<2)
    {
        printf("%s msgid\n",argv[0]);
        exit(1);
    }

    if(msgctl(atoi(argv[1]),IPC_STAT,&buf)==-1)
        err("copy msgstatus faild");

    printf("\tmsg_perm:\n");
    printf("\t\tuid\tgid\tcuid\tcgid\tmode\tkey\n");
    printf("\t\t%4d\t%4d\t%4d\t%4d\t%4d\t0x%x\n",buf.msg_perm.uid,buf.msg_perm.gid,\
            buf.msg_perm.cuid,buf.msg_perm.cgid,buf.msg_perm.mode,\
            buf.msg_perm.__key);
    printf("\tmsg_qnum\tmsg_qbytes\tmsg_cbytes\n");
    printf("\t%8d\t%8d\t%8d\n",buf.msg_qnum,buf.msg_qbytes,buf.__msg_cbytes);

    return 0;


}
